package com.rookie.rabbit.modular.demo.enums;

import com.rookie.rabbit.modular.util.RabbitUtils;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author rookie
 */

@Getter
@AllArgsConstructor
public enum BindEnum {

    /**
     * 路由键
     */
    TEST_BIND(ExchangeEnum.DEFAULT_EXCHANGE, QueueEnum.EMAIL_PUSH, null, null),

    EMAIL_BIND(ExchangeEnum.DEFAULT_EXCHANGE, QueueEnum.EMAIL_PUSH, "email.push.key", "emailBind"),

    SMS_BIND(ExchangeEnum.DEFAULT_EXCHANGE, QueueEnum.SMS_PUSH, "sms.push.key", "smsBind"),

    USER_ONE_BIND(ExchangeEnum.FANOUT_EXCHANGE, QueueEnum.USER_ONE_QUEUE, "", "userOneBind"),

    USER_TWO_BIND(ExchangeEnum.FANOUT_EXCHANGE, QueueEnum.USER_TWO_QUEUE, "", "userTwoBind"),

    USER_ORDER_BIND(ExchangeEnum.TOPIC_EXCHANGE, QueueEnum.USER_ORDER_QUEUE, "user.*.key", "userOrderBind"),

    USER_LOGOUT_BIND(ExchangeEnum.TOPIC_EXCHANGE, QueueEnum.USER_LOGOUT_QUEUE, "user.*.key", "userLogoutBind"),

    SYSTEM_NOTICE_BIND(ExchangeEnum.TOPIC_EXCHANGE, QueueEnum.SYSTEM_NOTICE_QUEUE, "system.*.key", "systemNoticeBind");

    private ExchangeEnum exchangeEnum;

    private QueueEnum queueEnum;

    /**
     * 默认根据枚举名称转换
     */
    private String key;

    /**
     * 默认根据枚举名称转换
     */
    private String beanName;

    public String getKey(){
        return RabbitUtils.getDefaultRoutingKey(this,this.key);
    }
}
